<template>
  <div>
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item><i class="el-icon-date"></i> 机构管理</el-breadcrumb-item>
        <el-breadcrumb-item>机构添加</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="container">
      <el-form :model="form" :rules="rules" ref="form" label-width="80px">
        <el-form-item label="机构编号" prop="code">
          <el-input v-model="form.code" type="input"  ></el-input>
        </el-form-item>
        <el-form-item label="机构名称" prop="name">
          <el-input  v-model="form.name" type="input"  ></el-input>
        </el-form-item>
      
        <el-form-item>
          <el-button type="primary" @click="submit('form')">确认添加</el-button>

        </el-form-item>
      </el-form>



    </div>
  </div>
</template>

<script>
  import 'quill/dist/quill.core.css';
  import 'quill/dist/quill.snow.css';
  import 'quill/dist/quill.bubble.css';
  import { quillEditor } from 'vue-quill-editor';
  export default {
    data: function(){
      return {
        form: {
          code: '',
          name:'',
        },
        rules: {
          code: [
            { required: true, message: '请输入机构代码', trigger: 'blur' }
          ],
          name: [
            { required: true, message: '请输入部门名称', trigger: 'blur' }
          ]
        },
        content: '',
        editorOption: {
          placeholder: '开始编辑'
        },

      }
    },
    components: {
      quillEditor
    },
    computed:{

    },
    mounted :function(){

    },
    methods: {
      onEditorChange({editor, html, text}) {
        this.content = html;
      },
      submit(formName) {
        this.add()
        //this.$message.success('提交成功！');
      },

      add() {
        let that = this
        //发送请求
        this.HttpUtil.encryptPost(
          this,
          this.Global.URLPATH.MECHANISM_ADD,
          this.form,
          function (data) {

            that.$message.success("添加成功");
            sessionStorage.setItem("remove_this","/mechanism/add");
            that.$router.push({path: '/mechanism/index'})
            that.form =  {
              code: '',
              name:'',
            }
          },
          function (data) {//访问失败
            that.$message.success(data.msg);
          });
      }
    }
  }
</script>
<style scoped>
  .editor-btn{
    margin-top: 20px;
  }
</style>
